home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_17.lha / 6_17 / 6_17a9.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  507b  |  21 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / x = v1 / v2
  6. include <minmax.h>    /* DELETE */
  7. ector& operator/(vector &v1, vector &v2)
  8.  
  9.    // allocate the new vector
  10.    int l = min(v1.p->length, v2.p->length);
  11.    vector *v = new vector(l);
  12.  
  13.    // do the operations
  14.    float *f = v->p->f;
  15.    float *f1 = v1.p->f;
  16.    float *f2 = v2.p->f;
  17.    for (int i = 0; i < l; i++, f1++, f2++)
  18. *f++ = *f1 / *f2;
  19.    return *v;
  20.  
  21.